export function cycletime(time) {
    const year = time.getFullYear();
    const month = time.getMonth() + 1;
    const day = time.getDate();
    const hours = time.getHours();
    const minters = time.getMinutes();
    const second = time.getSeconds();
    const Times = {
        year: year,
        month: Zero(month),
        day: Zero(day),
        hours: Zero(hours),
        minters: Zero(minters),
        second: Zero(second)
    };
    return Times;
}

export function lastTime(time) {
    const nowTime = new Date();
    const lastDate = new Date(nowTime - 1000 * 60 * 60 * 24 * time);

    return cycletime(lastDate);
}

export function Zero(time) {
    if (time < 10) {
        return `0${time}`;
    }
    return `${time}`;
}
